#include "includes.h"

#define TASK_STK_SIZE 128

#define LED_B P36
#define LED_Y P35
#define LED_G P37

// ==== 实时任务堆栈定义 ============
OS_STK Task_STK_0[TASK_STK_SIZE];
OS_STK Task_STK_1[TASK_STK_SIZE];
OS_STK Task_STK_2[TASK_STK_SIZE];

void Port0Init(void)
{
    /* 设置P0为强推挽输出 */
    P3M0 = 0xff;
    P3M1 = 0x00;
    P3   = 0x00;
}

void FLOPCheck0(void *p_arg)
{
    p_arg;
    while (1) {
        OSTimeDly(1000);
        LED_B = !LED_B;
    }
}

void FLOPCheck1(void *p_arg)
{
    p_arg;
    while (1) {
        OSTimeDly(500);
        LED_Y = !LED_Y;
    }
}

void FLOPCheck2(void *p_arg)
{
    p_arg;
    while (1) {
        OSTimeDly(2000);
        LED_G = !LED_G;
    }
}

void main(void)
{
    Port0Init();

    OSInit();
    OSTaskCreate(FLOPCheck0, (void *)0, (OS_STK *)&Task_STK_0[0], 2);
    OSTaskCreate(FLOPCheck1, (void *)0, (OS_STK *)&Task_STK_1[0], 3);
    OSTaskCreate(FLOPCheck2, (void *)0, (OS_STK *)&Task_STK_2[0], 4);
    OSStart();
}